| 1234567891011121314151617181920212223242526272829303132333435 |
- import { NextResponse } from "next/server";
- import { listYears } from "@/lib/storage";
- /**
- * GET /api/branches/[branch]/years
- *
- * Returns the list of year folders for a given branch.
- * Example: /api/branches/NL01/years → { branch: "NL01", years: ["2023", "2024"] }
- */
- export async function GET(request, ctx) {
- // Next.js 16: params are resolved asynchronously via ctx.params
- const { branch } = await ctx.params;
- console.log("[/api/branches/[branch]/years] params:", { branch });
- // Basic validation of required params
- if (!branch) {
- return NextResponse.json(
- { error: "branch Parameter fehlt" },
- { status: 400 }
- );
- }
- try {
- const years = await listYears(branch);
- return NextResponse.json({ branch, years });
- } catch (error) {
- console.error("[/api/branches/[branch]/years] Error:", error);
- return NextResponse.json(
- { error: "Fehler beim Lesen der Jahre: " + error.message },
- { status: 500 }
- );
- }
- }
|